package tools

import (
	"regexp"
	"strconv"
)

func Numbers(input string) []string {
	re := regexp.MustCompile(`\d+`)
	matches := re.FindAllString(input, -1)
	return matches
}
func FirstNumber(input string) string {
	re := regexp.MustCompile(`\d+`)
	match := re.FindString(input)
	return match
}
func FirstNumberInt(input string) int {
	str := FirstNumber(input)
	count, err := strconv.Atoi(str)
	if err != nil {
		return 0
	}
	return count
}
func LastNumber(input string) string {
	re := regexp.MustCompile(`\d+`)
	match := re.FindAllString(input, -1)
	return match[len(match)-1]
}

func LastNumberInt(input string) int {
	str := LastNumber(input)
	count, err := strconv.Atoi(str)
	if err != nil {
		return 0
	}
	return count
}
